package com.ebeijia.controller;

import com.ebeijia.dto.PaymentDto;
import com.ebeijia.query.OrderQuery;
import com.ebeijia.query.Paginator;
import com.ebeijia.service.admin.OrderInfoService;
import com.ebeijia.util.DateUtil;
import com.ebeijia.web.ResponseMessage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * Created by YPJ on 2016/5/18.
 */

@Controller
@RequestMapping("/order")
public class OrderInfoController {
    @Resource
    private OrderInfoService orderInfoService;

    @RequestMapping("/toPayList.htm")
    public ModelAndView toPayList() {
        ModelAndView modelAndView = new ModelAndView("order/orderList");
        return modelAndView;
    }

    @RequestMapping("/payList.json")
    @ResponseBody
    public ResponseMessage payList(OrderQuery orderQuery) {

       List<PaymentDto> paymentDtoList = orderInfoService.selectPayList(orderQuery);
        Paginator<PaymentDto> paginator = new Paginator<PaymentDto>(orderQuery,
            orderInfoService.selectPayList(orderQuery), orderInfoService.selectPayCount(orderQuery));
        return ResponseMessage.success(paginator);
    }
}
